#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Shu Yang Wang
# Date: 2017/11/13
from django.forms import Form, fields, widgets
from pro_cmdb.models import CallCircuit

class LoginForm(Form):
    """
    登陆表单
    """
    username = fields.CharField(required=True, error_messages={"required":"用户名不能为空"},
                                widget=widgets.TextInput(attrs={"class":"form-control","id":"inputEmail3"}))
    password = fields.CharField(required=True, error_messages={"required":"密码不能为空"},
                                widget=widgets.PasswordInput(
                                    attrs={"class":"form-control","id":"inputEmail3"}
                                ))


class AddEditHostsForm(Form):
    """
    添加修改服务器表单
    """
    Name = fields.CharField(required=True,  error_messages={"required":"服务器名不能为空"},
                            widget=widgets.TextInput(attrs={"class": "form-control", "placeholder": "主机名"}))
    IP = fields.GenericIPAddressField(required=True,  error_messages={"required":"IP不能为空"},protocol='both',
                            widget=widgets.TextInput(attrs={"class": "form-control", "placeholder": "主机IP"}))
    CPU = fields.IntegerField(required=True,  error_messages={"required":"CPU不能为空"},
                            widget=widgets.TextInput(attrs={"class": "form-control", "placeholder": "CPU"}))
    Mem = fields.IntegerField(required=True,  error_messages={"required":"Mem不能为空"},
                            widget=widgets.TextInput(attrs={"class": "form-control", "placeholder": "Mem"}))
    callCircuit_id = fields.ChoiceField(choices=[],
                            widget=widgets.Select(attrs={'class': 'form-control'}))

    def __init__(self, *args, **kwargs):
        super(AddEditHostsForm, self).__init__(*args, **kwargs)
        self.fields['callCircuit_id'].choices = CallCircuit.objects.values_list('id', 'Name')

class CallCircuitForm(Form):
    '''
    业务线表的增加，修改
    '''
    Name = fields.CharField(required=True, error_messages={'required': '业务线不能为空'},
                            widget=widgets.TextInput(attrs={"class": "form-control", "placeholder": "业务线名称"})
                            )